package com.liuceng.peatio.service

import com.liuceng.BaseSpec
import com.liuceng.peatio.model.NewRptMemberMediumMobileDailyFlow

/**
 * Created by yanwen on 16-5-9.
 */
class NewRptMemberMediumDailyFlowServiceSpec extends BaseSpec {
    def "测试 获取没有处理的数据"() {
        given:
        NewRptMemberMediumDailyFlowService service = Spy()
        service.findNotDealedMobileData(_ as Map<String, Integer>) >> { params ->
            Integer id = params.get(0).get("memberId")
            if (id == 1) {
                List<NewRptMemberMediumMobileDailyFlow> list = [new NewRptMemberMediumMobileDailyFlow(memberId: 1, mediumId: 1), new NewRptMemberMediumMobileDailyFlow(memberId: 1, mediumId: 2), new NewRptMemberMediumMobileDailyFlow(memberId: 1, mediumId: 3)]
                return list
            }
            if (id == 2) {
                List<NewRptMemberMediumMobileDailyFlow> list = [new NewRptMemberMediumMobileDailyFlow(memberId: 2, mediumId: 1), new NewRptMemberMediumMobileDailyFlow(memberId: 2, mediumId: 3)]
                return list
            }
            if (id == 3) {
                List<NewRptMemberMediumMobileDailyFlow> list = [new NewRptMemberMediumMobileDailyFlow(memberId: 3, mediumId: 1), new NewRptMemberMediumMobileDailyFlow(memberId: 3, mediumId: 2), new NewRptMemberMediumMobileDailyFlow(memberId: 3, mediumId: 3)]
                return list
            }
            return null
        }

        /* service.findMobileData(_ as Map<String, Integer>,_ as Integer ) >> { params ,type->
              List<NewRptMemberMediumMobileDailyFlow> list = [new NewRptMemberMediumMobileDailyFlow(memberId: 1, mediumId: 1), new NewRptMemberMediumMobileDailyFlow(memberId: 1, mediumId: 2), new NewRptMemberMediumMobileDailyFlow(memberId: 1, mediumId: 3)]
              return list
          }*/

        List<Map<String, Integer>> memberIds = [["member_id": 1], ["member_id": 2], ["member_id": 3], ["member_id": 4]]
        Map<String, Integer> params = new HashMap<>()
        when:
        Map<Integer, List<NewRptMemberMediumMobileDailyFlow>> result = service.findNotDealedMobileDataConvertMap(memberIds, params)
        then:
        result.size() == 3
        and:
        result.get(1).size() == 3
        and:
        result.get(2).size() == 2
        and:
        result.get(3).size() == 3
        and:
        result.get(4) == null

    }

}
